/**
 * @param {number[]} nums
 * @return {number}
 */
var findPeakElement = function(nums) {
    let left = 0, right = nums.length - 1;
    while (left < right) {
        let lmid = (left + right) >> 1;
        let rmid = lmid + 1;
        if (nums[lmid] <= nums[rmid]) left = lmid + 1;
        else right = rmid - 1;
    }
    return right;
}